package com.gym.code.config.admin.bean.method;

import org.apache.commons.lang.StringUtils;

import com.gym.code.generator.EnumContants.EnumIdAware;

/**
 * 
 * @author xinchun.wang 
   @email: 532002108@qq.com
 * @createTime 2015-4-11 下午5:45:57
 */
public class MethodColumnMappingBaseBean {
	protected long id;
	protected long methodId;
	protected long columnId;
	protected FunctionMappingType mappingType = FunctionMappingType.parameter;
	
	protected String beginParameterName;
	protected String endParameterName;
	
	protected int listFlag;
	
	public String getBeginParameterName() {
		return beginParameterName;
	}

	public void setBeginParameterName(String beginParameterName) {
		this.beginParameterName = beginParameterName;
	}

	public String getEndParameterName() {
		return endParameterName;
	}

	public void setEndParameterName(String endParameterName) {
		this.endParameterName = endParameterName;
	}

	public int getListFlag() {
		return listFlag;
	}
	
	public boolean isList() {
		return listFlag == 1;
	}
	
	public boolean isBetween(){
		if(StringUtils.isNotEmpty(beginParameterName) && StringUtils.isNotEmpty(endParameterName)){
			return true;
		}
		return false;
	}
	
	public String getListFlagStr() {
		return listFlag==1 ? "YES":"NO";
	}

	public void setListFlag(int listFlag) {
		this.listFlag = listFlag;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}


	public long getMethodId() {
		return methodId;
	}

	public void setMethodId(long methodId) {
		this.methodId = methodId;
	}


	public long getColumnId() {
		return columnId;
	}

	public void setColumnId(long columnId) {
		this.columnId = columnId;
	}

	public FunctionMappingType getMappingType() {
		return mappingType;
	}

	public void setMappingType(FunctionMappingType mappingType) {
		this.mappingType = mappingType;
	}
	
	public void setMappingType(int mappingType) {
		this.mappingType = FunctionMappingType.getById(mappingType);
	}
	

	/**
	 * @author xinchun.wang 
	   @email: 532002108@qq.com
	 * @createTime 2015-4-26 下午3:16:55
	 */
	public static enum FunctionMappingType implements EnumIdAware {
		parameter(1), result(2),update(3);

		private FunctionMappingType(int id) {
			this.id = id;
		}

		private int id;

		public int getId() {
			return this.id;
		}

		public static FunctionMappingType getById(int id) {
			for (FunctionMappingType item : values()) {
				if (item.getId() == id) {
					return item;
				}
			}
			return null;
		}

	}
}
